target = codesters.Sprite("triangle", -150, -100)
target.set_opacity(.5)
target.reflect_y_axis()
target.translate_x(50)
target.translate_y(100)
text = codesters.Text('target', 150, -10)
text.set_opacity(.7)
text.set_size(.8)
stage.set_background("grid")
sprite = codesters.Sprite("triangle", -150, -100)
t =codesters.Teacher()
# possible answers
# sprite.rotate_origin(180)
# sprite.translate_x(50)
# sprite.reflect_y(50)
# sprite.reflect_y_axis()
# sprite.translate_x(50)
# sprite.translate_y(100)
# sprite.translate_y(100)
# sprite.reflect_y_axis()
# sprite.translate_x(50)
try:
tval1 = sprite.get_x()
tval2 = sprite.get_y()
except:
tval1 = "DNE"
tval2 = "DNE"
try:
tval3 = sprite.get_rotation()
except:
tval3 = "DNE"
if tval1 == 200 and tval2 == 0 and tval3 == 180:
text.set_text( ' ' )
t1 = TestObjective()
t1.add_success(tval1 == 200 and tval2 == 0 and tval3 == 180, "Great job!")
t1.add_failure(tval1 == "DNE", "Oops! Did you delete your sprite?")
t1.add_failure(tval1 == -150 and tval2 == -100 and tval3 == 0, "Try adding transformations to map your sprite onto the target triangle!")
t1.add_failure(tval1 == -100 and tval2 == 0 and tval3 == 0, "Almost there! Try adding a reflection or rotation!")
t1.add_failure(tval3 == 180 and (tval1 != 200 or tval2 != 0), "That's the right orientation! How can you slide the triangle into place?")
t1.add_failure(tval1 == 200 and tval2 == 0 and tval3 == 0, "Your point is in the right place, but your triangle isn't facing the right direction!")
tester = TestManager()
tester.display_graphics = False
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)